package com.mosai.smartmedical;

import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

public class PageThreeActivity extends AppCompatActivity {
    public static final String TAG = PageThreeActivity.class.getSimpleName();

    public static int index;
    private int cIndex;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ++index;
        cIndex = index;
        setContentView(R.layout.activity_page_three);
        Log.i(TAG, "onCreate: " + cIndex + " " + this);
        TextView textView = findViewById(R.id.textView);
        textView.setText("Page Three " + cIndex);
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        Log.i(TAG, "onNewIntent: " + cIndex);
    }

    public void onPageOne(View v) {
        Intent intent = new Intent(this, PageOneActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.i(TAG, "onDestroy: " + cIndex + " " + this);
    }

    public void onPageThree(View view) {
        Intent intent = new Intent(this, PageThreeActivity.class);
//        intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
    }
}
